package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.AgedmallBusiAdminMapper;
import org.linlinjava.litemall.db.dao.AgedmallBusinessInfoMapper;
import org.linlinjava.litemall.db.domain.AgedmallBusiAdmin;
import org.linlinjava.litemall.db.domain.AgedmallBusiAdminExample;
import org.linlinjava.litemall.db.domain.AgedmallBusinessInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AgedmallBusinessInfoService {

    @Resource
    private AgedmallBusinessInfoMapper agedmallBusinessInfoMapper;

    @Resource
    private AgedmallBusiAdminMapper agedmallBusiAdminMapper;

    public AgedmallBusinessInfo findByBusId(Integer id) {
        return agedmallBusinessInfoMapper.selectByPrimaryKey(id);
    }

    /**
     * 是否为店铺管理员
     * @param uid
     * @return
     */
    public int isExistsBusiAdmin(int uid) {
        AgedmallBusiAdminExample busiAdminExample = new AgedmallBusiAdminExample();
        busiAdminExample.createCriteria().andUserIdEqualTo(uid).andDeletedEqualTo(false);
        return (int) agedmallBusiAdminMapper.countByExample(busiAdminExample);
    }
}
